#include "def.h"

void AddVex(Graph &G){	
    if (G.vertexNum == MaxSize) {
        cout<<"已达到最大顶点数，无法添加新的景点。"<<endl;
    }
	else{	
	    cout<<"请输入新景点的信息"<<endl<<"景点名字：";
	    cin.getline(G.vexs[G.vertexNum].name, MaxSize);
	    cout<<"景点介绍：";
	    cin.getline(G.vexs[G.vertexNum].info, 512);
	    
	    printInfo(G);
		int index=0; 
	    while(index!=-1){//输入-1就结束 	    
		    cout<<"该景点与哪一个景点之间有路径（输入景点序号）：";
		    cin>>index;
		    if(index==-1) break;
		    
		    cout<<"与"<<G.vexs[index-1].name<<"的距离为：";
			int distance;
			cin>>distance;
			
			G.arcs[G.vertexNum][index-1]=distance;
			G.arcs[index-1][G.vertexNum]=distance;
						
		    cout<<"与该景点之间的路径已经添加成功！\n（Enter继续添加路径/-1结束）\n" ;
		    cin.ignore();
		    if(cin.get()=='\n') continue;
		    else break;
		}
	    
	    G.vertexNum++;
		WriteMap(G);
	    cout<<"添加成功！按任意键返回主菜单..."<<endl;
	    getch();
	}
}